package com.secfound.soccer.client.tools;

import java.util.List;

import com.secfound.soccer.shared.db.Bet;
import com.secfound.soccer.shared.db.Game;

/**
 * Extracts a sublist for pagination purposes
 * @author alfonso.ayala
 *
 */
public class PageExtractor {
	public static List<Bet> extractBetPage(List<Bet> fullBetList, int page, int pageLength) {
		int fromIndex=(page-1)*pageLength;
		int toIndex=((page)*pageLength)-1;
		if(toIndex>fullBetList.size()){
			toIndex=fullBetList.size();
		}
		return fullBetList.subList(fromIndex, toIndex);
	}
	public static List<Game> extractGamePage(List<Game> fullBetList, int page, int pageLength) {
		int fromIndex=(page-1)*pageLength;
		int toIndex=((page)*pageLength)-1;
		if(toIndex>fullBetList.size()){
			toIndex=fullBetList.size();
		}
		return fullBetList.subList(fromIndex, toIndex);
	}
}
